
#ifndef WISHMASTER_TASKREQUESTBOARD_H
#define WISHMASTER_TASKREQUESTBOARD_H

#include <QObject>
#include <QUrl>
#include <boost/signals2.hpp>
#include "components/postid.h"
#include "components/threadid.h"
#include "task.h"
#include "misc.h"
#include "requestmanager.h"

namespace Wishmaster
{
	class WISHMASTER_EXPORT TaskRequest: public Task
	{
		Q_OBJECT
	public:
		enum RequestType
		{
			rtUnknown = 0,
			rtBoard,
			rtThread,
			rtPost,
			rtAttachment,
			rtOther = 1000
		};
		TaskRequest(RequestType type, const Wishmaster2::Network::Url& link, const QString& msg, Wishmaster2::Network::RequestManager* requestManager);
		virtual ~TaskRequest();

		RequestType requestType() const;
		Wishmaster2::Network::Url link() const;

		virtual void start();
		virtual void cancel();

	protected:
		Wishmaster2::Network::RequestPtr request() const;

		virtual void onRequestDone();

	signals:
		void result(TaskRequest* task, const QByteArray& arr, const QString& contentType);

	protected slots:
		void slot_progress(int done, int total);

	private:
		void requestDone(int requestId);

	private:
		RequestType m_type;
		Wishmaster2::Network::RequestPtr m_request;
		PostId m_postId;
		int m_attachmentIndex;
		Wishmaster2::Network::Url m_link;
		Wishmaster2::Network::RequestManager* m_requestManager;
	};
}

#endif

